package options

import (
	"cgs-server/internal/cgserver/global"
	"github.com/spf13/pflag"
)

// MinIOptions minio options
type MinIOptions struct {
	Endpoint        string `json:"endpoint" mapstructure:"endpoint"`
	AccessKeyId     string `json:"access-key-id" mapstructure:"access-key-id"`
	SecretAccessKey string `json:"secret-access-key" mapstructure:"secret-access-key"`
}

// NewMinIOptions creates a MinIOptions object with default parameters.
func NewMinIOptions() *MinIOptions {
	if global.ReleaseType == "PUBLIC" {
		return &MinIOptions{
			Endpoint:        "127.0.0.1:9000",
			AccessKeyId:     "cgsminio",
			SecretAccessKey: "W3FjXeiLgT0Rdgi5R7eRQC9B29XhczeR",
		}
	}
	return &MinIOptions{}
}

func (m *MinIOptions) Validate() []error {
	errs := []error{}

	return errs
}

func (m *MinIOptions) AddFlags(fs *pflag.FlagSet) {
	fs.StringVar(&m.Endpoint, "minio.endpoint", m.Endpoint, ""+
		"MinIO service host address.")

	fs.StringVar(&m.AccessKeyId, "minio.access-key-id", m.AccessKeyId, ""+
		"Access key id for access to minio service.")

	fs.StringVar(&m.SecretAccessKey, "minio.secret-access-key", m.SecretAccessKey, ""+
		"Secret access key for access to minio service.")
}
